package com.aopeng.service.impl;

import java.io.File;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author <a href="mailto:juhui.chen@vtradex.com">陈局辉</a>
 * @since 2020-11-27 16:22
 */
@Configuration
public class MyConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        File fileDir = new File("classpath:src/main/resources/static/img/word/");
        //和页面有关的静态目录都放在项目的static目录下
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        //上传的图片在D盘下的image目录下，访问路径如：http://localhost:8080/image/slt/d3cf0281-bb7f-40e0-ab77-406db95ccf2c.jpg
        //其中image/slt表示访问的前缀。"file:D:/image/slt/"是文件真实的存储路径
        registry.addResourceHandler("/img/word/**").addResourceLocations("file:/usr/local/tomcat/image/");
//        registry.addResourceHandler("/img/**").addResourceLocations("file:D:/图/");
    }
}
